/*
 * sensors.h
 *
 * Created: 14/07/2011 21:21:34
 *  Author: guy
 */ 



#ifndef SENSORS_H_
#define SENSORS_H_

#include <inttypes.h>
#include <math.h>

#define SEN_AX 0
#define SEN_AY 1
#define SEN_AZ 2
#define SEN_GX 3
#define SEN_GY 4
#define SEN_GZ 5
#define SEN_MX 6
#define SEN_MY 7
#define SEN_MZ 8
#define SEN_B  9

#define cR 0 // i.e. roll around teh x axis +ve is right wing down
#define cP 1 // pitch = rotation around teh y axis - +ve is pitch up
#define cY 2 // yaw around teh z axis - +ve is x axis moving cw towards y


#define NPOINT_AVERAGE           2   //N point average definition (shift definition) = 4  (1<<2)
// These two Should be the same as but make sure that NPOINT_FILTER_ACCURACY*NPOINT_AVERAGE < 32767

//ADXL345
#define ADXL_ADDR			0xA6
#define ADXL_ID				0xE5
#define ADXL_SENSITIVITY    (256)  // LSB/g

//L3G4200D
#define L3GD20_ADDR			0xD6
#define L3GD20_ID			0xD4
#define L3G4200D_ADDR			0xD2
#define L3G4200D_ID				0xD3
#define L3G4200D_MDPS_PER_DIGIT 70.0f   // this value from datasheet - for 2000 DPS  0.007 deg/sec/digit
#define L3G4200D_DPS_PER_DIGIT  (L3G4200D_MDPS_PER_DIGIT/1000.0f)
#define L3G4200D_TO_RPS(x)      (float(x)*L3G4200D_DPS_PER_DIGIT*M_PI/180.0f)

//HMC5883L
#define HMC5883L_ADDR 0x3C
#define HMC5883L_ID1  0x48

void	populateSensorData();
void	calibrateGyro();
void calibrateCompass();
uint8_t adxl_init();
uint8_t l3g4200d_init();
uint8_t HMC5883L_init();

extern int16_t sensor_data_int[10];

#endif /* SENSORS_H_ */
